/**
 * @User: vitobo
 * @Date: 2024-05-17
 * @Description:  this引用, 代表当前对象的引用, 当前对象(谁调用这个方法,谁就是this)
 *                this.成员变量
 *                this.成员方法
 *                this()  访问构造方法
 *
 *                建议写上 this
 */
public class TestDate {
    public int year;
    public int month;
    public int day;

    // 局部变量优先,只是形参自己给自己赋值了, 根本没有赋值到成员变量当中
//    public void setDate(int year, int month, int day){
//        year = year;
//        month = month;
//        day = day;
//    }


    public void setDate(TestDate this, int y, int m, int d){
        this.year = y;
        this.month = m;
        this.day = d;
    }

//    public void setDate(int year, int month, int day){
//        this.year = year;
//        this.month = month;
//        this.day = day;
//    }


    public void printDate(){
        System.out.println(year + "-" + month + "-" + day);
    }

    public void func(){
        this.printDate();
    }

    public static void main(String[] args) {
        TestDate testDate1 = new TestDate();
        TestDate testDate2 = new TestDate();
        TestDate testDate3 = new TestDate();

        testDate1.setDate(2024, 5, 17);
        testDate2.setDate(2024, 6, 17);
        testDate3.setDate(2024, 7, 17);

        testDate1.printDate();
        testDate2.printDate();
        testDate3.printDate();

    }


    public static void main1(String[] args) {
        TestDate testDate = new TestDate();
        testDate.setDate(2024, 5, 17);
        testDate.printDate();

        System.out.println("*************");
    }
}
